<style lang="scss" scoped>
@import '@/assets/css/variable';
.courseContainer{
	width: 100%;
	background-color: $bgw;
	min-height: 100%;
	font-size: 1.2rem;
	overflow-y: scroll;
	box-sizing: border-box;
	flex:1;
	background-color: $main-bgc-gray;
  background-color: #fff;
	padding: 10px 10px 46px 10px;
    
	.popBox{
			padding: 12px 13px;
			.title{
				font-size: 16px;
				color: #191F25;
				padding-bottom: 12px;
			}
			.list{
				.item{
					padding: 12px 0;
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 14px;
					border-top: 1px solid #f7f7f7;
					.text{
						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-line-clamp:1; /* 设置行数 */
						-webkit-box-orient:vertical;
						color: #191F25;
					}
					.downBtn{
						color: $mainColor;
						flex: 0 0 50px;
						text-align: right;
					}
					&:last-child{
						border-bottom: 1px solid #f7f7f7;
					}
				}
			}
		}

	.fix-bottom{
			position: fixed;
			bottom: 6px;
			left: 12px;
			right: 12px;
			.btn{
				height: 40px;
				line-height: 40px;
				/* 表单底色 */
				background: #F5F7FA;
				/* 分割线用色 */
				
				border: 1px solid #F0F2F5;
				box-sizing: border-box;
				border-radius: 8px;
				text-align: center;
				color: #707070;
				font-size: 16px;
			}
		}	
}


</style>

<template>
	<div class="courseContainer"> 
    <search-box @searchEvent="searchEvent"></search-box>

    <div class="list" v-for="(item, i) in policyList" :key="i" @click="sweiperClick(item)" >
		<info-list :renderList = "item"></info-list>
	</div>




    <div class="fix-bottom">
			<div class="btn" @click="downloadBtn">下载附件</div>
		</div>
       <van-popup v-model="showPop" position="bottom" round :style="{ height: '50%' }">
		   <div class="popBox" >
				<div class="title">附件列表({{policyList.length}}条)
           </div>
				<div class="list" v-for="(item, i) in policyList" :key="i">
					<div class="item">
						<span class="text">{{StickTitle(item.content)}}</span>
						<a  :href="item.img" class="downBtn">下载</a>
					</div>
            </div>
		</div>
	   </van-popup>

        
	</div>

	
</template>

<script>
import { myMixins } from "@/assets/js/mixins.js"
import BarNav from '@/components/BarNav'
import InfoList from '@/components/InfoList.vue'
import SearchBox from '@/components/SearchBox'




export default {
	mixins: [myMixins],
	name: 'course',
	data() {
		return {
			showPop: false,
            policyList: []
		}
	},
	components: {
		BarNav,
		InfoList,
		SearchBox
	},
    created() {
      this.policyList = this.$store.state.policyData
    },

    // 处理文本标签
	computed: {
	  StickTitle() {
	  return function(value) {
		let reg=/<\/?.+?\/?>/g;
		return value.replace(reg, '')
	  }
	}
    },

    
	watch: {
		
	},
	mounted() {
		
	},
	methods: {
	downloadBtn() { this.showPop = true },
    sweiperClick(value) {
      this.$router.push('/infoDetail')
	  this.$store.commit('setInfoback', value)
    },
    // 搜索
	searchEvent(value) {
       this.$request.InterpretationList({
		params: {
		pageNo: 1,
		pageSize: 10,
		sreWhere: value
	  }}).then(res => {
	  console.log(res.result.records, 'title');
	  let popsdata = res.result.records
        popsdata.map(item => {
            if(item.filesUrl == null) return
            item.img = this.$request.url(item.filesUrl[0])
			return item.img
       })
	
	  this.policyList = popsdata
      console.log(this.policyList, 33333333);
	
	  })
	}

		
	},
	
}

</script>